﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace VmcRemote.Common
{
    [global::System.AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class DefaultPortAttribute : Attribute
    {
        // This is a positional argument
        public DefaultPortAttribute(int number)
        {
            this.Number = number;
        }

        public int Number { get; private set; }

        public static int GetDefaultPort(Type type)
        {
            object[] attrs = type.GetCustomAttributes(typeof(DefaultPortAttribute), false);
            if (attrs != null && attrs.Length > 0)
                return ((DefaultPortAttribute)attrs[0]).Number;
            return 0;
        }
    }
}
